package com.xingkeduo.util.pojo.domain;

import java.util.List;

import com.xingkeduo.util.pojo.base.BaseTable;

/**
 * 分页信息类
 * 
 * @author GJ
 * @time 2019年2月21日 上午11:05:52
 * @description
 */
public class Page<T extends BaseTable<T>> {
	private int recordStart;
	private int recordEnd;
	private int recordTotal;
	private int pageSize;
	private int pageNo;
	private int pageTotal;
	private List<T> dtoList;

	public Page() {
	}

	public Page(int pageNo, int pageSize) {
		this.pageNo = pageNo;
		this.pageSize = pageSize;
	}

	public void init(int totalRow) {
		this.recordTotal = totalRow;
		if ((totalRow != 0) && (totalRow % this.pageSize == 0)) {
			this.pageTotal = totalRow / this.pageSize;
		} else {
			this.pageTotal = totalRow / this.pageSize + 1;
		}

		if (totalRow == 0) {
			this.recordStart = 0;
		} else {
			this.recordStart = (this.pageNo - 1) * this.pageSize;
		}

		this.recordEnd = this.pageSize;
	}

	public int getRecordStart() {
		return recordStart;
	}

	public void setRecordStart(int recordStart) {
		this.recordStart = recordStart;
	}

	public int getRecordEnd() {
		return recordEnd;
	}

	public void setRecordEnd(int recordEnd) {
		this.recordEnd = recordEnd;
	}

	public int getRecordTotal() {
		return recordTotal;
	}

	public void setRecordTotal(int recordTotal) {
		this.recordTotal = recordTotal;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageTotal() {
		return pageTotal;
	}

	public void setPageTotal(int pageTotal) {
		this.pageTotal = pageTotal;
	}

	public List<T> getDtoList() {
		return dtoList;
	}

	public void setDtoList(List<T> dtoList) {
		this.dtoList = dtoList;
	}
}
